<?php
/**
 * Railed
 * @package railed
 * @author Rob Frawley <robfrawley@inserrat.com>
 * @license GNU Public License v2
 * @version $Id: general.php 2 2007-02-28 07:48:04Z robfrawley $
 */

/**
 * magic autoloader function for classes
 * @param string $class_name
 */
function __autoload($class_name)
{
  $matches = array();
  preg_match("/[A-Z][a-z]*/", $class_name, $matches);
  if(is_array($matches) === false || sizeof($matches) > 0)
  {
    $class_directory = $matches[0] . DIR_SEP;
  }
  else
  {
    $class_directory = '';
  }
  $class_path = DIR_CLASSES . $class_directory . $class_name . FILE_EXT_LIBRARY;
  if((@include_once $class_path) === false)
  {
    die('Could not include required class path ' . $class_path . '.');
  }
  if((class_exists($class_name) === false) && (interface_exists($class_name) === false))
  {
    die('Included file ' . $class_path . ' does not contain a declaration for required class ' . $class_name . '.');
  }
}
?>